
CREATE TABLE [dbo].[Video](
	[Video_ID] [uniqueidentifier] NOT NULL,
	[Video_Code] [int] NULL,
	[Event_ID] [uniqueidentifier] NOT NULL,
	[URL] [nvarchar](200) NULL,
	[Caption] [nvarchar](max) NULL,
	[Duration] [nvarchar](10) NULL,
	[IsFavorite] [bit] NULL,
	[IsVisible] [bit] NULL,
	[Order] [int] NULL,
	[Date_Created] [datetime] NULL,
	[Date_Modified] [datetime] NULL,
 CONSTRAINT [PK_Video] PRIMARY KEY CLUSTERED 
(
	[Video_ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Video]  WITH CHECK ADD  CONSTRAINT [FK_Video_Video] FOREIGN KEY([Video_ID])
REFERENCES [dbo].[Video] ([Video_ID])
GO

ALTER TABLE [dbo].[Video] CHECK CONSTRAINT [FK_Video_Video]
GO

ALTER TABLE [dbo].[Video] ADD  CONSTRAINT [DF_Video_Video_ID]  DEFAULT (newid()) FOR [Video_ID]
GO

ALTER TABLE [dbo].[Video] ADD  CONSTRAINT [DF_Video_Date_Created]  DEFAULT (getdate()) FOR [Date_Created]
GO

ALTER TABLE [dbo].[Video] ADD  CONSTRAINT [DF_Video_Date_Modified]  DEFAULT (getdate()) FOR [Date_Modified]
GO

-- Change to the PicturePeople table
ALTER TABLE PicturePeople ALTER COLUMN Picture_ID uniqueidentifier null
GO
ALTER TABLE PicturePeople ADD Video_ID uniqueidentifier null
Go
ALTER TABLE [dbo].[PicturePeople]  WITH CHECK ADD  CONSTRAINT [FK_PicturePeople_Video] FOREIGN KEY([Video_ID])
REFERENCES [dbo].[Video] ([Video_ID])
GO
ALTER TABLE [dbo].[PicturePeople] CHECK CONSTRAINT [FK_PicturePeople_Video]
GO